package com.atguigu.chaptar3

object $04_Abstract {
  abstract class Animal{
    val age = 20
    def hello()=print("hello")
     val name:String
    def add(x:Int,y:Int):Int
  }
  class Pig extends Animal{
    override val name: String = "zhangsan"

    override def add(x: Int, y: Int)= x+y
  }

  def main(args: Array[String]): Unit = {
    val pig = new Pig
    println(pig.name)
    println(pig.add(3, 5))
    val animal = new Animal {
      override val name: String = "xiaowang"

      override def add(x: Int, y: Int): Int = x - y
    }
  }

}
